package com.moxiao.yfjh.module.activity.dal.mysql.packageInfo;

import java.util.*;

import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import com.moxiao.yfjh.module.activity.dal.dataobject.packageInfo.PackageInfoDO;
import org.apache.ibatis.annotations.Mapper;
import com.moxiao.yfjh.module.activity.controller.admin.packageInfo.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 相亲套餐信息 Mapper
 *
 * @author mx
 */
@Mapper
public interface PackageInfoMapper extends BaseMapperX<PackageInfoDO> {

    default PageResult<PackageInfoDO> selectPage(PackageInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PackageInfoDO>()
                .eqIfPresent(PackageInfoDO::getNo, reqVO.getNo())
                .likeIfPresent(PackageInfoDO::getName, reqVO.getName())
                .eqIfPresent(PackageInfoDO::getPackageType, reqVO.getPackageType())
                .eqIfPresent(PackageInfoDO::getSuitActivity, reqVO.getSuitActivity())
                .eqIfPresent(PackageInfoDO::getBoyNum, reqVO.getBoyNum())
                .eqIfPresent(PackageInfoDO::getGirlNum, reqVO.getGirlNum())
                .eqIfPresent(PackageInfoDO::getOptProduct, reqVO.getOptProduct())
                .eqIfPresent(PackageInfoDO::getPrice, reqVO.getPrice())
                .eqIfPresent(PackageInfoDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(PackageInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PackageInfoDO::getId));
    }

    default List<PackageInfoDO> selectList(PackageInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PackageInfoDO>()
                .eqIfPresent(PackageInfoDO::getNo, reqVO.getNo())
                .likeIfPresent(PackageInfoDO::getName, reqVO.getName())
                .eqIfPresent(PackageInfoDO::getPackageType, reqVO.getPackageType())
                .eqIfPresent(PackageInfoDO::getSuitActivity, reqVO.getSuitActivity())
                .eqIfPresent(PackageInfoDO::getBoyNum, reqVO.getBoyNum())
                .eqIfPresent(PackageInfoDO::getGirlNum, reqVO.getGirlNum())
                .eqIfPresent(PackageInfoDO::getOptProduct, reqVO.getOptProduct())
                .eqIfPresent(PackageInfoDO::getPrice, reqVO.getPrice())
                .eqIfPresent(PackageInfoDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(PackageInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PackageInfoDO::getId));
    }

    @Select("select count(*) num from blind_package_info where no = #{packageInfoNo}")
    Integer getPackageInfoNo(@Param("packageInfoNo") String packageInfoNo);

}
